/**
 * 
 */
package com.sx.fams.task.action;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.alibaba.fastjson.JSONArray;
import com.opensymphony.xwork2.ModelDriven;
import com.sx.core.BaseAction;
import com.sx.fams.task.biz.ITaskBiz;
import com.sx.fams.task.entity.TaskEntity;

/**
 * @author LQZ
 * @date Sep 2, 2012	
 * 任务
 */
@SuppressWarnings("serial")
public class TaskAction extends BaseAction implements ModelDriven<TaskEntity> {
	private Log log = LogFactory.getLog(this.getClass());
	private TaskEntity task = new TaskEntity();
	private ITaskBiz taskbiz;
    public TaskAction(){}  
    /**
     * 获取团组列表数据信息
     ***/
    public void getTaskInfoForList(){
    	String str = "{totalCount:0,data:[]}";
    	try {
			String total = taskbiz.queryTaskCounts(task);
			List<TaskEntity> list = taskbiz.queryTaskInfos(task);
			str = "{totalCount:"+total+",data:"+JSONArray.toJSONString(list)+"}";
    	} catch (Exception e) {
			log.error("获取出国团组数据信息失败请查明原因",e);
			// TODO: handle exception
		}
		outJsonString(str);
    }
	/**
	 * 编辑出国信息
	 **/
	public void applyFms(){
		int clength = task.getCountryids().length;
		log.error("======="+clength+"=======");
		taskbiz.addTaskInfo(task);
		super.outJsonString("{success:true}");
	}
	/* (non-Javadoc)
	 * @see com.opensymphony.xwork2.ModelDriven#getModel()
	 */
	public TaskEntity getModel() {
		// TODO Auto-generated method stub
		return task;
	}
	/**
	 * @return the taskbiz
	 */
	public ITaskBiz getTaskbiz() {
		return taskbiz;
	}
	/**
	 * @param taskbiz the taskbiz to set
	 */
	public void setTaskbiz(ITaskBiz taskbiz) {
		this.taskbiz = taskbiz;
	}
	
}
